<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>系统消息推送管理</title>
    <!--  引入vue.js  因为Element UI 依赖vue -->
    <script src="../ep/static/js/vue.js"></script>
    <!--  引入element组件库 -->
    <script src="../ep/static/js/element.js"></script>
    <!-- element 引入样式 -->
    <link rel="stylesheet" href="../ep/static/elementui/theme-chalk/index.css">
    <script src="../ep/static/js/axios.js"></script>


</head>
<body>
<div id="app">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item label="课程名称" prop="name">
            <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item label="讲师" prop="region">
            <el-select v-model="ruleForm.region" placeholder="请选择讲师">
                <el-option label="区域一" value="shanghai"></el-option>
                <el-option label="区域二" value="beijing"></el-option>
            </el-select>
        </el-form-item>

        <el-form-item label="直播简介" prop="desc">
            <el-input type="textarea" v-model="ruleForm.desc"></el-input>
        </el-form-item>

        <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
        </el-form-item>
    </el-form>
</div>
</body>
<script type="text/javascript">
    new Vue({
        el: '#app',
        input: '',
        data: {
            ruleForm: {
                name: '',
                region: '',
                date1: '',
                date2: '',
                delivery: false,
                type: [],
                resource: '',
                desc: ''
            },
            rules: {
                name: [{
                    required: true,
                    message: '请输入课程名称',
                    trigger: 'blur'
                },
                    {
                        min: 3,
                        max: 5,
                        message: '长度在 3 到 5 个字符',
                        trigger: 'blur'
                    }
                ],
                region: [{
                    required: true,
                    message: '请选择讲师',
                    trigger: 'change'
                }],
                desc: [{
                    required: true,
                    message: '请填写直播简介',
                    trigger: 'blur'
                }]
            }

        },
        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        alert('submit!');
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            }
        }


    })
</script>
</html>
